using System;
using System.IO;

using Microsoft.TeamFoundation.Server;
using Microsoft.VisualStudio.TestTools.UnitTesting;

using Microsoft.Services.TfsAlert.TfsAlertScenarioTests.NotificationRecieverProxy;

namespace Microsoft.Services.TfsAlert.TfsAlertScenarioTests
{
    [TestClass]
    public class NotificationEvent
    {
        NotificationReciever _notificationReciever = null;
        SubscriptionInfo _subscriptionInfo = null;

        [TestInitialize]
        public void TestInitialize()
        {
            _notificationReciever = new NotificationReciever();
            _notificationReciever.Url = @"http://localhost:9999/TFSAlert";

            _subscriptionInfo = new SubscriptionInfo();
            _subscriptionInfo.ID = 123;
            _subscriptionInfo.Subscriber = "asdfasdfasdf";
        }

        [TestMethod]
        [DeploymentItem(@"TfsAlertScenarioTests\TestMessages\CheckinEvent.xml")]
        public void CheckinEvent()
        {
            string checkinEventXml = File.ReadAllText( @"CheckinEvent.xml" ); 
            _notificationReciever.Notify(
                checkinEventXml,
                "tfsIdentityXML",
                _subscriptionInfo);
        }

        [TestMethod]
        [DeploymentItem(@"TfsAlertScenarioTests\TestMessages\WorkItemChangedEvent.xml")]
        public void WorkItemChanged()
        {
            string eventXml = File.ReadAllText(@"WorkItemChangedEvent.xml");
            _notificationReciever.Notify(
                eventXml,
                "tfsIdentityXML",
                _subscriptionInfo);
        }

    }
}
